<?php
namespace app\backend\model;

use think\Cache;
use think\Model;
use think\Session;

class sys_user extends Model
{
    private $loginkey = "__admin__";
    public function login($params)
    {
        $user = self::get($params);
        if($user){
            return $user->data;
        }else{
            return null;
        }

    }
    public function isLogin(){
        if(Session::has($this->loginkey)){
            return true;
        }else{
            return false;
        }
    }
    public function getLoginUser(){
        return Session::get($this->loginkey);
    }
    public function clearSessionUser(){
        Session::delete($this->loginkey);
    }
    public function setSessionUser($user){
        Session::set($this->loginkey,$user);
    }
}